# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=nextcloud-client
pkgver=2.6.4
pkgrel=0
pkgdesc="Nextcloud Desktop Client"
url="https://github.com/nextcloud/desktop"
# mips, s390x and ppc64le blocked by qt5-qtwebengine
# armhf blocked by extra-cmake-modules
arch="all !s390x !ppc64le !armhf !mips !mips64"
license="GPL-2.0-only"
makedepends="$depends_dev cmake doxygen qt5-qttools-dev qt5-qtkeychain-dev
	graphviz extra-cmake-modules kio-dev qt5-qtwebengine-dev"
subpackages="$pkgname-dev $pkgname-dolphin"
options="!check" # no testsuite
source="$pkgname-$pkgver.tar.gz::https://github.com/nextcloud/desktop/archive/v${pkgver/_p/-fix}.tar.gz
	Nextcloud.conf"
builddir="$srcdir/desktop-${pkgver/_p/-fix}"

build() {
	cmake \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc/$pkgname \
		-DNO_SHIBBOLETH=TRUE \
		-DMIRALL_VERSION_SUFFIX=""
	make all
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 "$srcdir"/Nextcloud.conf "$pkgdir"/etc/Nextcloud/Nextcloud.conf
}

dolphin() {
	pkgdesc="$pkgdesc - KDE Dolphin integration"
	install_if="$pkgname dolphin"

	mkdir -p "$subpkgdir"/usr/lib "$subpkgdir"/usr/share

	mv "$pkgdir"/usr/lib/qt5 "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/libnextclouddolphinpluginhelper.so "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/share/kservices5 "$subpkgdir"/usr/share/
}

sha512sums="849bf9bfa6a50342f6b58e805dc72ef342cb5f3e2e27d8f45d6a48759b1956dec194fb376b9a6b760df724f01eec3a22aadaa439f03e5166b1b2afb5454e40f1  nextcloud-client-2.6.4.tar.gz
28faf643e3ba22f3e1f45a96acfba1b3c53c49d4e923974e58e5ad2fdda612f52300608f0e0219e61d3478403fe3c59a9a2c70c3db1c93fbccda1e0638ecbc22  Nextcloud.conf"
